package com.doit.day02;

import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Table;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;

public class _11_删除数据 {
    public static void main(String[] args) throws IOException {
        Connection conn = HbaseUtil.getConn();
        Table table = conn.getTable(TableName.valueOf("doit:table_name"));

        ArrayList<Delete> deletes = new ArrayList<>();
//        Delete delete = new Delete("rowkey_001".getBytes(StandardCharsets.UTF_8));
//        delete.addColumn("f1".getBytes(StandardCharsets.UTF_8),"name".getBytes(StandardCharsets.UTF_8));
//        delete.addColumn("f1".getBytes(StandardCharsets.UTF_8),"address".getBytes(StandardCharsets.UTF_8));
//        delete.addColumn("f2".getBytes(StandardCharsets.UTF_8),"age".getBytes(StandardCharsets.UTF_8));
//        delete.addColumn("f3".getBytes(StandardCharsets.UTF_8),"gender".getBytes(StandardCharsets.UTF_8));
        Delete delete1 = new Delete("rowkey_002".getBytes(StandardCharsets.UTF_8));
        delete1.addFamily("f1".getBytes(StandardCharsets.UTF_8));

//        Delete delete2 = new Delete("abcrui".getBytes(StandardCharsets.UTF_8));
//        Delete delete3 = new Delete("abchr".getBytes(StandardCharsets.UTF_8));
//        deletes.add(delete);
        deletes.add(delete1);
//        deletes.add(delete2);
//        deletes.add(delete3);

        table.delete(deletes);
        table.close();
        conn.close();
    }
}
